package com.ruoyi.app.controller

import com.ruoyi.anno.NotResubmit
import com.ruoyi.app.common.Data
import com.ruoyi.app.domain.dto.*
import com.ruoyi.app.domain.vo.FunctionIndexVo
import com.ruoyi.app.domain.vo.SingleTemplateMemberInfo
import com.ruoyi.app.service.RecordApiService
import com.ruoyi.app.service.TemplateApiService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("api/userRecord")
@Api(tags = ["作品相关接口"])
class RecordApiController {

    @Autowired
    private lateinit var recordApiService: RecordApiService

    @Autowired
    private lateinit var templateApiService: TemplateApiService


    @ApiOperation("获取用户作品列表")
    @GetMapping("getUserRecordList")
    fun getUserRecordList(myRecordSearchDto: MyRecordSearchDto): Data<List<FunctionIndexVo>> =
        recordApiService.getUserRecordList(myRecordSearchDto)

    @ApiOperation("保存用户作品")
    @PostMapping("addUserRecord")
    fun addUserRecord(@RequestBody myRecordDto: MyRecordDto): Data<Boolean> =
        recordApiService.addUserRecord(myRecordDto)

    @ApiOperation("制作换脸视频")
    @PostMapping("videoChangeFaceDto")
    @NotResubmit(delaySeconds = 10)
    fun addUserVideoChangeFace(@RequestBody videoChangeFaceDto: VideoChangeFaceDto): Data<Boolean> =
        recordApiService.addUserVideoChangeFace(videoChangeFaceDto)

    @ApiOperation("制作图片换脸")
    @PostMapping("addUserPicChangeFace")
    @NotResubmit(delaySeconds = 5)
    fun addUserPicChangeFace(@RequestBody imageChangeFaceDto: ImageChangeFaceDto): Data<Boolean> =
        recordApiService.addUserPicChangeFace(imageChangeFaceDto)

    @ApiOperation("推荐用户作品")
    @PostMapping("recommendUserRecord")
    fun recommendUserRecord(appTemplateRecommendDto: AppTemplateRecommendDto): Data<Boolean> =
        templateApiService.recommendUserRecord(appTemplateRecommendDto)

    @ApiOperation("单次收费会员信息")
    @GetMapping("singleTemplateMemberInfo")
    fun singleTemplateMemberInfo(templateInfo: RecordApiService.TemplateInfo): Data<SingleTemplateMemberInfo?> =
        recordApiService.singleTemplateMemberInfo(templateInfo)

    @ApiOperation("批量移除用户记录")
    @GetMapping("removeUserRecord/{ids}")
    @ApiImplicitParams(
        ApiImplicitParam(
            name = "ids",
            value = "多个id使用逗号隔开",
            type = "path",
            required = true
        )
    )
    fun removeUserRecord(@PathVariable ids: String): Data<Boolean> = recordApiService.removeUserRecord(ids)
}